<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登陆表单</title>
    <script src="/jquery/dist/jquery.min.js"></script>
    <script src="/jquery/jquery-form.js"></script>
    <script src="/layer/layer.js"></script>
    <script src="/layui/layui.js"></script>
    <script src="/commonjs/util.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/registForm.css">
</head>
<body style="padding-right: 40px">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>用户登陆</legend>
</fieldset>
<form class="layui-form" id="loginForm" action="../../user/login">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" lay-verify="required" lay-reqtext="用户名不能为空" autocomplete="off"
                   placeholder="请输入用户名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" lay-verify="required" lay-reqtext="密码不能为空" placeholder="请输入密码"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="login">登陆</button>
            <button type="button" class="layui-btn layui-btn-primary">忘记密码</button>
        </div>
    </div>
</form>
<script>
    layui.use('form', function () {
        var form = layui.form;
        form.render();
    });

    $(function () {
        /** 注册表单提交，后台验证后的回调  */
        $("#loginForm").ajaxForm(function (data) {
            if (data.state == 1) {
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
                parent.popMessage("登陆成功")
                parent.window.location = "/index";
            } else {
                parent.popMessage(data.message);
            }
        });
    });

</script>
</body>
</html>